$(function(){	
	
	// ie9 bug on home page
	if( ($.browser.msie && $.browser.version == '9.0') &&  $("#intro-slider").length )
	{
		$('body').css('overflow', 'auto');
	}
	
	var interval;
	
	// Home Page Images Slider
	
	if ( $("#intro-slider").length  )
	{
		$("#intro-slider").roundabout({
			'duration': '1500',
			'minOpacity': 1,
			'easing': 'easeOutExpo',
			'reflect': 'false'			
		});
		
	}
	
	$("table#prices tbody tr td").hover(function() {
		
		var index = $(this).index();
		
		if( index != 0 )
		{
			$("table#prices tbody tr").find("td:eq("+index+")").each(function(i) {
				$(this).addClass('selected');
			});	
		}
		
	}, function() {
		$("table#prices tbody tr td").removeClass('selected');
	});
	
	// Contact Form Drop Down Menu
	if( $("select.select").length > 0 )
	{
		$("select.select").msDropDown();		
		
	}
	
	// Home Page Icon Tag Cloud
	if( $('#icon-tags').length )
	{
		$('#icon-tags').tagcloud();
	}
	
	
	// Products Menu
	$("div#products-menu ul#products-list li:first-child").addClass('first-menu-item');
	$("div#products-menu ul#services-menu li:last-child").addClass('last-menu-item');	
		
	// Packages Menu
	$("div#packages-menu ul li a").live('click', function() {
		
		// Variables
		var btn 		= $(this).parent();
		var btnId 		= $(this).parent().attr('id');
		var allbtn 		= $("div#packages-menu ul li");
		var containerId = $(this).attr('href');
		var container 	= $("div.single-package-container");
		var arrow 		= $("div#active-arrow");
		var index 		= $(this).parent().index();
		var topPX 		= 22;
		
		switch( index ) {
			case 0:
			topPX = 22;
			break;		
			case 1:
			topPX = 95;
			break;			
			case 2:
			topPX = 170;
			break;			
			case 3:
			topPX = 245; 
			break;			
			case 4:
			topPX = 325; 
			break;		
			case 5:
			topPX = 400; 
			break;		
		}
						
		// Actions
		$(arrow).stop().animate({ top: topPX }, 'slow');
		$(container).hide();
		$(containerId).fadeIn();		
		$(allbtn).removeAttr('class');
		$(btn).addClass(btnId+'-active');		
		
		return false;
	});
	
	
	// /* Product Content Tabs */
	$("a#tab-app-btn").live('click', function() {
		$(this).attr('id', 'tab-app-btn-active');
		$("a#tab-cms-btn-active").attr('id', 'tab-cms-btn');
		$("a#tab-like-btn-active").attr('id', 'tab-like-btn');
		$("a#tab-comment-btn-active").attr('id', 'tab-comment-btn');
		$("a#tab-rating-btn-active").attr('id', 'tab-rating-btn');
		
		$("div#app-content").fadeIn();
		$("div#cms-content, div#like-content, div#comment-content, div#rating-content").hide();
		return false;
	});
	
	$("a#tab-cms-btn").live('click', function() {
		$(this).attr('id', 'tab-cms-btn-active');
		$("a#tab-app-btn-active").attr('id', 'tab-app-btn');		
		$("a#tab-like-btn-active").attr('id', 'tab-like-btn');
		$("a#tab-comment-btn-active").attr('id', 'tab-comment-btn');
		$("a#tab-rating-btn-active").attr('id', 'tab-rating-btn');
		
		$("div#cms-content").fadeIn();
		$("div#app-content, div#like-content, div#comment-content, div#rating-content").hide();
		return false;
	});
	
	$("a#tab-like-btn").live('click', function() {
		$(this).attr('id', 'tab-like-btn-active');
		$("a#tab-app-btn-active").attr('id', 'tab-app-btn');
		$("a#tab-cms-btn-active").attr('id', 'tab-cms-btn');				
		$("a#tab-comment-btn-active").attr('id', 'tab-comment-btn');
		$("a#tab-rating-btn-active").attr('id', 'tab-rating-btn');
		
		$("div#like-content").fadeIn();
		$("div#app-content, div#cms-content, div#comment-content, div#rating-content").hide();
		return false;
	});

	
	$("a#tab-comment-btn").live('click', function() {
		$(this).attr('id', 'tab-comment-btn-active');
		$("a#tab-app-btn-active").attr('id', 'tab-app-btn');
		$("a#tab-cms-btn-active").attr('id', 'tab-cms-btn');				
		$("a#tab-like-btn-active").attr('id', 'tab-like-btn');
		$("a#tab-rating-btn-active").attr('id', 'tab-rating-btn');
		
		$("div#comment-content").fadeIn();
		$("div#app-content, div#cms-content, div#like-content, div#rating-content").hide();
		return false;
	});
	
	$("a#tab-rating-btn").live('click', function() {
		$(this).attr('id', 'tab-rating-btn-active');
		$("a#tab-app-btn-active").attr('id', 'tab-app-btn');
		$("a#tab-cms-btn-active").attr('id', 'tab-cms-btn');				
		$("a#tab-like-btn-active").attr('id', 'tab-like-btn');
		$("a#tab-comment-btn-active").attr('id', 'tab-comment-btn');
		
		$("div#rating-content").fadeIn();
		$("div#app-content, div#cms-content, div#like-content, div#comment-content").hide();
		return false;
	});
	
	

	// Full Button
	$("a.full-btn").live('click', function(){		
		$("div#full-content").slideDown(function(){
			$("a.full-btn").hide();
		$("a.short-btn").show();
		});
		return false;
	});
	
	// Short Button
	$("a.short-btn").live('click', function(){
		$("div#full-content").slideUp(function() {
			$("a.short-btn").hide();
			$("a.full-btn").show();
		});
		return false;
	});
	
	/*
	// Contact Form Variables
	var $name = $("input#name");
	var $phone = $("input#phone");
	var $email = $("input#email");
	var $organization = $("input#organization");
	
	// Actions on Focus
	$name.live('focus', function() { if( $name.val() == 'სახელი, გვარი' ) { $name.val(''); } });
	$phone.live('focus', function() { if( $phone.val() == 'ტელეფონი' ) { $phone.val(''); } });
	$email.live('focus', function() { if( $email.val() == 'ელფოსტა' ) { $email.val(''); } });
	$organization.live('focus', function() { if( $organization.val() == 'ორგანიზაცია' ) { $organization.val(''); } });
	
	// Actions on Blur
	$('input').bind('blur',function() {		
		if( $name.val() == '' ) { $name.val('სახელი, გვარი'); }
		if( $phone.val() == '' ) { $phone.val('ტელეფონი'); }
		if( $email.val() == '' ) { $email.val('ელფოსტა'); }
		if( $organization.val() == '' ) { $organization.val('ორგანიზაცია'); }
	});
	*/
	
	// Contact Form Variables
	var contactValue = '';	
	$("input:text").focus(function(){
		if( $(this).val() == $(this).attr('title') )
		{
			contactValue = $(this).val();
			$(this).val('');
		}		
	});	
	
	$("input:text").blur(function(){
		if( $(this).val() == "" )
		{			
			$(this).val(contactValue);
		}		
	});
	
	// Prices Tables Corners
	//$("div#prices-table-container").append('<span class="tc ttl"></span><span class="tc tbl"></span>');
	//$("div#special-prices-container").append('<span class="tc ttl"></span><span class="tc tbl"></span><span class="tc tbr"></span><span class="tc ttr"></span>');
	
	// $("td.highlight").append('<div class="h-c"><div class="h-l"></div><div class="h-r"></div></div>');
	// $("th.highlight-header").append('<div class="h-c"><div class="h-h-l"></div><div class="h-h-r"></div><div class="h-t"></div><div class="h-t-l"></div><div class="h-t-r"></div></div>');
	// $("td.highlight-footer").append('<div class="h-c"><div class="h-f-l"></div><div class="h-f-r"></div><div class="h-b"></div><div class="h-b-l"></div><div class="h-b-r"></div></div>');
	
});


